<template>
  <div class="overview-chart-wrapper">
    <div class="chart-wrapper-box">
      <div class="contract-chart-wrapper">
        <div class="chart-titles">
          详情数据
        </div>
        <div class="contract-chart-wrap1">
          <div v-for="(item, index) in dataList" :key="index" class="contract-chart-wrap-item">
            <div class="staff-top-item-icon">
              <!-- <img :src="item.img" class="imgBox" /> -->
              <xq-icon :type="item.icon" class="primary_color imgBox" style="font-size: 40px" />
            </div>
            <div class="item-top-item-box">
              <div class="staff-top-item-name">{{ item.name }}</div>
              <div class="staff-top-item-num">{{ item.num }}</div>
            </div>
            <div class="staff-top-item-bottom">
              <div class="img" v-if="item.compareNum !== '--'">
                上月
                <img :src="upImg" v-if="item.compareNum > 0" style="height:12px;width:12px;margin-bottom:3px" />
                <img :src="downImg" v-if="item.compareNum < 0" style="height:12px;width:12px;margin-bottom:3px" />
                <span v-if="item.compareNum > 0" style="color:#FF5550FF">{{ item.compareNum }}</span>
                <span v-if="item.compareNum < 0" style="color:#24CDAAFF">{{ item.compareNum }}</span>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
const dataList = [
  {
    icon: "icon-yanglaobaoxian1",
    name: "养老保险（元）",
    num: "--",
    compareNum: "--"
  },
  {
    icon: "icon-yiliaobaoxian",
    name: "医疗保险（元）",
    num: "--",
    compareNum: "--"
  },
  {
    icon: "icon-shiyebaoxian",
    name: "失业保险（元）",
    num: "--",
    compareNum: "--"
  },
  {
    icon: "icon-gongshangbaoxian",
    name: "工伤保险（元）",
    num: "--",
    compareNum: "--"
  },
  {
    icon: "icon-shengyubaoxian",
    name: "生育保险（元）",
    num: "--",
    compareNum: "--"
  },
  {
    icon: "icon-dabingyibao",
    name: "补充大病医保（元）",
    num: "--",
    compareNum: "--"
  },
  {
    icon: "icon-buchongyanglao",
    name: "补充养老保险（元）",
    num: "--",
    compareNum: "--"
  },
  {
    icon: "icon-canbaojin",
    name: "残保金（元）",
    num: "--",
    compareNum: "--"
  },
  {
    icon: "icon-qita",
    name: "其他（元）",
    num: "--",
    compareNum: "--"
  }
];
import { selectSocProgItem } from "@/api/shebao/statistic";
export default {
  props: {
    dateBox: {
      type: Object,
      default() {
        return {
          dataOfNum: []
        };
      }
    },
    queryType: {
      type: Number,
      default: 0
    }
  },
  data() {
    return {
      borderImg: require("@/assets/img/statistic/border.png"),
      upImg: require("@/assets/img/statistic/rise.png"),
      downImg: require("@/assets/img/statistic/down2.png"),
      detailList: {},
      companyId: this.$store.state.hr.companyId,
      dataList
    };
  },

  watch: {
    dateBox: {
      handler: function(val, oldVal) {
        this.grtSelectSocProgItem();
      },
      deep: true
    },
    queryType: {
      handler: function(val, oldVal) {
        this.grtSelectSocProgItem();
      },
      deep: true
    }
  },
  created() {
    // this.grtSelectSocProgItem();
  },

  methods: {
    grtSelectSocProgItem() {
      selectSocProgItem({
        companyId: this.companyId,
        startMonth: this.dateBox.startMonth,
        endMonth: this.dateBox.endMonth,
        startYear: this.dateBox.startYear,
        endYear: this.dateBox.endYear,
        queryType: this.queryType,
        step: this.dateBox.step,
        isAcrossYear: this.dateBox.startYear !== this.dateBox.endYear
      }).then(res => {
        this.detailList = res.data.socDetail;
        this.dataList[0].num = res.data.socDetail["养老保险"] ? res.data.socDetail["养老保险"] : "--";
        this.dataList[1].num = res.data.socDetail["医疗保险"] ? res.data.socDetail["医疗保险"] : "--";
        this.dataList[2].num = res.data.socDetail["失业保险"] ? res.data.socDetail["失业保险"] : "--";
        this.dataList[3].num = res.data.socDetail["工伤保险"] ? res.data.socDetail["工伤保险"] : "--";
        this.dataList[4].num = res.data.socDetail["生育保险"] ? res.data.socDetail["生育保险"] : "--";
        this.dataList[8].num = res.data.socDetail["其他"] ? res.data.socDetail["其他"] : "--";
        this.dataList[0].compareNum = res.data.socDetailDifference["养老保险"] ? res.data.socDetailDifference["养老保险"] : "--";
        this.dataList[1].compareNum = res.data.socDetailDifference["医疗保险"] ? res.data.socDetailDifference["医疗保险"] : "--";
        this.dataList[2].compareNum = res.data.socDetailDifference["失业保险"] ? res.data.socDetailDifference["失业保险"] : "--";
        this.dataList[3].compareNum = res.data.socDetailDifference["工伤保险"] ? res.data.socDetailDifference["工伤保险"] : "--";
        this.dataList[4].compareNum = res.data.socDetailDifference["生育保险"] ? res.data.socDetailDifference["生育保险"] : "--";
        this.dataList[8].compareNum = res.data.socDetailDifference["其他"] ? res.data.socDetailDifference["其他"] : "--";
      });
    }
  }
};
</script>
<style scoped lang="scss">
.overview-chart-wrapper {
  display: flex;
  margin-top: 23px;
  background-color: #fff;
  flex-direction: column;
}
.chart-wrapper-box {
  height: 255px;
  background-color: #fff;
  padding: 24px 0 0 24px;
  border-radius: 4px;
  .contract-chart-wrap1 {
    margin-top: 30px;
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    .contract-chart-wrap-item {
      width: 20%;
      display: flex;
      position: relative;
      margin-bottom: 40px;
    }
  }
  .item-top-item-box {
    margin-left: 15px;
  }
  .imgBox {
    width: 50px;
    height: 50px;
  }
  .staff-top-item-name {
    font-size: 14px;
    font-weight: 400;
    color: #595959;
    line-height: 20px;
  }
  .staff-top-item-num {
    font-size: 24px;
    font-weight: 600;
    color: #000000;
    line-height: 33px;
  }
}
.chart-title {
  font-size: 17px;
  font-family: PingFangSC-Medium, PingFang SC;
  font-weight: 500;
  color: #000000;
  line-height: 22px;
}
.staff-top-item-bottom {
  font-size: 12px;
  width: 100%;
  height: 25px;
  position: absolute;
  bottom: -25px;
  left: 15px;
}
.img {
  margin-left: 49px;
}
.chart-titles {
  border-left: 4px solid var(--primary);
  padding-left: 10px;
  font-size: 17px;
  font-family: PingFangSC-Medium, PingFang SC;
  font-weight: 500;
  color: #000000;
  line-height: 22px;
}
</style>
